﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace ZYStudios.Helper
{
    public static class ImageLinkHelper
    {
        public static string ImageLink(this HtmlHelper htmlHelper, string imgSrc, string alt, string actionName, string controllerName)
        {
            UrlHelper urlHelper = ((Controller)htmlHelper.ViewContext.Controller).Url;
            string imgtag = "<img src='" + imgSrc + "' alt='"+alt+"'/>";
            string url = urlHelper.Action(actionName, controllerName);



            TagBuilder imglink = new TagBuilder("a");
            imglink.MergeAttribute("href", url);
            imglink.InnerHtml = imgtag;

            return imglink.ToString();

        }
    }
}